#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/5/31  15:29
# @Author: 余浪人
# @Email:yulangren520@Gmail.com

import requests, re
from fake_useragent import UserAgent
from queue import Queue
userAgent = UserAgent()
queue = Queue()


def download_get(url):
    try:
        domain = re.findall('^((https|http|ftp|rtsp|mms)?://[^\s]+)/', url)[0][0]
    except:
        domain = ""
    headers = {
        "User-Agent": userAgent.random,
        "Origin": domain,
        "Referer": domain
    }
    return requests.get(url=url, headers=headers)


def download_post(url, data=None):
    try:
        domain = re.findall('^((https|http|ftp|rtsp|mms)?://[^\s]+)/', url)[0][0]
    except:
        domain = ""
    headers = {
        "User-Agent": userAgent.random,
        "Origin": domain,
        "Referer": domain
    }
    return requests.post(url=url, data=data, headers=headers)



if __name__ == '__main__':
    res = download_get('https://www.qqwanmei.com/')

